<?
namespace app\admin\controller\xiservice;

use app\common\controller\Backend;
use fast\Random;
use think\Cache;
use think\Config;
use think\Db;
use think\Lang;
use think\Response;
use think\Validate;

/**
 * Ajax异步请求接口
 * @internal
 */
class Ajax extends Backend
{

    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];
    protected $layout = '';


    public function upload()
    {
 		$file = request()->file('file');
        if(!$file){
            $this->error("请选择文件上传");
        }

  		$info = $file->validate(['ext'=>'pem'])->move(ROOT_PATH . 'public' . DS . 'uploads');

        if($info){

        	 $url = './uploads/'.str_replace('\\', '/', $info->getSaveName());
        	 $this->success(__('Uploaded successful'), '', ['url' => $url, 'fullurl' => cdnurl($url, true)]);
        }else{
        	$this->error($file->getError());
        }
    }

}